package se.webbzon.boltzmann.game.event;

import se.webbzon.boltzmann.game.character.AbstractCharacter;
import se.webbzon.boltzmann.game.sequence.Sequence;
import se.webbzon.oschi01.worldarea.WorldArea;
import se.webbzon.oschi01.worldobject.WorldObject;
import se.webbzon.oschi01.worldobject.WorldStaticObject;

public class LookAtEvent extends AbstractTargetEvent {
	
	// The world object associated with this walk event
	private final WorldObject binding;
	
	/*============================================================
	Constructors
	============================================================*/
	
	public LookAtEvent(Sequence sequence, WorldObject binding, String[] arguments) {
		super(sequence,arguments);
		this.binding = binding;
	}
	
	/*============================================================
	Public Methods
	============================================================*/

	@Override protected void onBegin(WorldArea world) {
		Object target = getTarget();
		if (target instanceof WorldStaticObject) {
			if (binding instanceof AbstractCharacter) {
				AbstractCharacter character = (AbstractCharacter) binding;
				character.setFacing((WorldStaticObject) target);
			}
		}
		end();
	}

	@Override protected void onEnd() {};

}
